<?php




/**
* Details of an entry in [ images ]
*/

$images = new images();
$image_id = $variable->get('id', 'integer', 0); # Entity ID
$code = $variable->get('code', 'string', ''); # Protection Code

# Direction of navigation with respect to the current ID
# Directions: previous | next
$action = $variable->get('action', 'string', 'none');
switch($action)
{
case 'previous':
case 'next':
	$image_id = $images->navigate_id($image_id, $action);
	break;
case 'none':
default:
}
#die($action);

# Allow slug images - validate the slug code first.
# http://gallery.sanjaal.com/smarty-framework/public_html/image-63-baby-in-sandbox.php
/*
Array
(
    [page] => image.php
    [image_id] => 63
    [slug] => baby-in-sandbox
)
#print_r($_GET); die();
*/

if(!$image_id)
{
	# Page was loaded without the ID paremeter
	stopper::url('images-direct-access-error.php?context=identity');
}
else
{
	if(!$images->is_valid($image_id, $code)) stopper::message('Invalid image request.', false);
	
	# Try to load the details
	if($images_details = $images->details($image_id, $code))
	{
		# We aim to reach here only.
		$smarty->assignByRef('images', $images_details);
		
		# Count the impressions
		$images->count_impressions($image_id, $code);

		# List of image sizes allowed to share
		$sizes = new sizes();
		$allowed_sizes = $sizes->allowed_sizes();
		$smarty->assignByRef('sizes', $allowed_sizes);
	}
	else
	{
		# Record not found
		stopper::url('images-direct-access-error.php?context=data');
	}
}
?>